using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

namespace Game.Framework
{
    public class PathUtils
    {
        public static readonly string ASSETSBASE = "Assets/AssetsPackage";
#if UNITY_ANDROID
        public static readonly string Targetname = "Android";
        public static readonly string ResVersion = AssetConfig.Instance.AndroidVersion;
        
#elif UNITY_IPHONE
        public static readonly string Targetname = "Iphone";
        public static readonly string ResVersion = AssetConfig.Instance.IOSVersion;
#endif
        public static readonly string BaseAssetDownLoadPath = AssetConfig.Instance.ResServer_Production_URL + "/" + Targetname;

#if UNITY_EDITOR
        public static readonly string BuildAssetPath = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("/Assets"))
                                                       + "/Bundles/" + Targetname + "/" + AssetConfig.Instance.PackageName + "/" + ResVersion;
        
        public static readonly string BuildVersionFileName = "PackageManifest_" + AssetConfig.Instance.PackageName + "_" + ResVersion;
        
        public static readonly string BuildManifestPath = BuildAssetPath + "/" + BuildVersionFileName + ".bytes";
        
        public static readonly string StreamingAssetsPath_PackageName = Application.streamingAssetsPath + "/" + AssetConfig.Instance.DefaultFolderName 
                                                                        + "/" + AssetConfig.Instance.PackageName;
                    
        public static string[] BuildVersionSuffix = {".bytes",".hash",".json"};
#endif     
        
        // 修正路径中的正反斜杠
        public static string StandardizationPath(string path)
        {
            return path.Replace(@"\", "/");
        }
        
        
        
        // 创建目录
        public static void CreateDirectory(string filePath)
        {
            if (!string.IsNullOrEmpty(filePath))
            {
                string dirName = Path.GetDirectoryName(filePath);
                if (!Directory.Exists(dirName))
                {
                    Directory.CreateDirectory(dirName);
                }
            }
        }
    }
}


